<!DOCTYPE html>
<html>
    <head>
        <title>Require Demo</title>
        <meta name="viewport"content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <script type="text/javascript" src="public/components/requirejs/require.js"></script>
        <script type="text/javascript">
            var domain = window.location.origin,
                $Share = {},
                $Global = {
                    client : 'amd',
                    domain : domain,
                    publicUrl : domain+'/public',
                    apiUrl : domain+'/apis/',
                    controller : domain+'/controllers', 
                    view : domain+'/views', 
                    currentModule : 'index',
                    cacheModule : {},
                };

            //配置文件
            requirejs.config({
                //config: {},
                enforceDefine : true,
                baseUrl: '/',
                paths: {
                    'jquery': $Global.publicUrl+'/components/jquery/jquery',
                    'util': $Global.publicUrl+'/components/util/util',
                    'text' :  $Global.publicUrl+'/components/requirejs/plugins/text', 
                    'css' :   $Global.publicUrl+'/components/requirejs/plugins/css',
                    'backbone' : $Global.publicUrl+'/components/backbone/backbone',
                    'underscore' : $Global.publicUrl+'/components/underscore/underscore',
                    'lang' : $Global.domain+'/i18n/en',
                },
                //shim,引入会存在一些问题见官网，不系统化,模块化，管理维护复杂,终极的解决方案是将所有shim托管代码都升级为含有可选的AMD define()调用。
                urlArgs: "v="+(new Date()).getTime(),
                //urlArgs: "v=1.0",
            });

            //requireType: 含有类别信息的字串值，如“timeout”，“nodefine”， “scripterror”
            //requireModules: 超时的模块名/URL数组。
            requirejs.onError = function(e) {
                console.log(e);
                throw e;
            };

            requirejs(['backbone','share','util','lang'],function(backbone,share,lang) {
                window.$Share = share;
                window.$Lang = lang;
                requirejs(['main','css!public/resource/css/main'],function(main) { 
                    $(document).ready(function(){
                        main.init();                
                    });
                })
            });

        </script>
    </head>
    <body>
    </body>
</html>


